package com.xbongbong.pro.enums.permission.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/6/12 15:02
 * @since v1.0
 */
@Getter
public enum AddProPermissionAliasEnum {

    /**
     * tb_pro_promission对应的alias字段
     */
    CUSTOMER_COMMUNICATE_ADD(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), "customerCommunicateAdd", ProPermissionAliasEnum.CUSTOMER_COMMUNICATE_ADD.getI18nMemo()),

    OPPORTUNITY_ADD(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), "opportunityAdd", ProPermissionAliasEnum.OPPORTUNITY_ADD.getI18nMemo()),

    CUSTOMER_ADD(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "customerAdd", ProPermissionAliasEnum.CUSTOMER_ADD.getI18nMemo()),

    CONTACT_ADD(XbbRefTypeEnum.CONTACT.getCode(), "contactAdd", ProPermissionAliasEnum.CONTACT_ADD.getI18nMemo()),

    CONTRACT_ADD(XbbRefTypeEnum.CONTRACT.getCode(), "contractAdd", ProPermissionAliasEnum.CONTRACT_ADD.getI18nMemo()),

    WORK_REPORT_ADD(XbbRefTypeEnum.WORK_REPORT.getCode(), "workReportAdd", ProPermissionAliasEnum.WORK_REPORT_ADD.getI18nMemo()),

    PURCHASE_ADD(XbbRefTypeEnum.PURCHASE.getCode(), "purchaseAdd", ProPermissionAliasEnum.PURCHASE_ADD.getI18nMemo()),

    SUPPLIER_ADD(XbbRefTypeEnum.SUPPLIER.getCode(), "supplierAdd", ProPermissionAliasEnum.SUPPLIER_ADD.getI18nMemo()),

    INSTOCK_ADD(XbbRefTypeEnum.INSTOCK.getCode(), "instockAdd", ProPermissionAliasEnum.INSTOCK_ADD.getI18nMemo()),

    OTHER_INSTOCK_ADD(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), "instockAdd", ProPermissionAliasEnum.INSTOCK_ADD.getI18nMemo()),

    PURCHASE_INSTOCK_ADD(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), ProPermissionAliasEnum.PURCHASE_INSTOCK_ADD.getAlias(),ProPermissionAliasEnum.PURCHASE_INSTOCK_ADD.getI18nMemo()),

    REFUND_INSTOCK_ADD(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), ProPermissionAliasEnum.REFUND_INSTOCK_ADD.getAlias(),ProPermissionAliasEnum.REFUND_INSTOCK_ADD.getI18nMemo()),

    PRODUCTION_INSTOCK_ADD(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_ADD.getAlias(),ProPermissionAliasEnum.REFUND_INSTOCK_ADD.getI18nMemo()),

    RETURNED_MATERIEL_INSTOCK_ADD(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_ADD.getAlias(),ProPermissionAliasEnum.REFUND_INSTOCK_ADD.getI18nMemo()),

    OUTSTOCK_ADD(XbbRefTypeEnum.OUTSTOCK.getCode(), "outstockAdd", ProPermissionAliasEnum.OUTSTOCK_ADD.getI18nMemo()),

    OTHER_OUTSTOCK_ADD(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), "outstockAdd", ProPermissionAliasEnum.OUTSTOCK_ADD.getI18nMemo()),

    CONTRACT_OUTSTOCK_ADD(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_ADD.getAlias(),ProPermissionAliasEnum.CONTRACT_OUTSTOCK_ADD.getI18nMemo()),

    WORK_ORDER_OUTSTOCK_ADD(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_ADD.getAlias(),ProPermissionAliasEnum.CONTRACT_OUTSTOCK_ADD.getI18nMemo()),

    PRODUCTION_MATERIEL_OUTSTOCK_ADD(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_ADD.getAlias(),ProPermissionAliasEnum.CONTRACT_OUTSTOCK_ADD.getI18nMemo()),

    RETURNED_PURCHASE_OUTSTOCK_ADD(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_ADD.getAlias(),ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_ADD.getI18nMemo()),

    INVENTORY_ADD(XbbRefTypeEnum.INVENTORY.getCode(), "inventoryAdd", ProPermissionAliasEnum.INVENTORY_ADD.getI18nMemo()),

    TRANSFER_ADD(XbbRefTypeEnum.TRANSFER.getCode(), "transferAdd", ProPermissionAliasEnum.TRANSFER_ADD.getI18nMemo()),

    WAREHOUSE_ADD(XbbRefTypeEnum.WAREHOUSE.getCode(), "warehouseAdd", ProPermissionAliasEnum.WAREHOUSE_ADD.getI18nMemo()),

    RETURN_PURCHASE_ADD(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), "returnPurchaseAdd", ProPermissionAliasEnum.RETURN_PURCHASE_ADD.getI18nMemo()),

    ASSEMBLE_ADD(XbbRefTypeEnum.ASSEMBLE.getCode(), "assembleAdd", ProPermissionAliasEnum.ASSEMBLE_ADD.getI18nMemo()),

    INVOICE_ADD(XbbRefTypeEnum.INVOICE.getCode(), "invoiceAdd", ProPermissionAliasEnum.INVOICE_ADD.getI18nMemo()),

    WORK_ORDER_ADD(XbbRefTypeEnum.WORK_ORDER.getCode(), "workOrderAdd", ProPermissionAliasEnum.WORK_ORDER_ADD.getI18nMemo()),

    BOM_BILL_ADD(XbbRefTypeEnum.BOM_BILL.getCode(), "bomBillAdd", ProPermissionAliasEnum.BOM_BILL_ADD.getI18nMemo()),

    PRODUCTION_ORDER_ADD(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), "productionOrderAdd", ProPermissionAliasEnum.PRODUCTION_ORDER_ADD.getI18nMemo()),

    COMMUNICATE_PLAN_ADD(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), "communicatePlanAdd", ProPermissionAliasEnum.COMMUNICATE_PLAN_ADD.getI18nMemo()),

    PRODUCT_ADD(XbbRefTypeEnum.PRODUCT.getCode(), "productAdd", ProPermissionAliasEnum.PRODUCT_ADD.getI18nMemo()),

    PAY_PLAN_ADD(XbbRefTypeEnum.PAY_PLAN.getCode(), "payPlanAdd", ProPermissionAliasEnum.PAY_PLAN_ADD.getI18nMemo()),
    //新建权限被删除了
    //51306 【KA】应收款和回款单权限控制漏洞-紧急！ 这里得放开，不知道这里为啥之前注释掉
    PAYMENT_ADD(XbbRefTypeEnum.PAYMENT.getCode(), "paymentAdd", ProPermissionAliasEnum.PAYMENT_ADD.getI18nMemo()),
    PAYMENT_RED_ADD(XbbRefTypeEnum.RED_RECEIVABLES.getCode(), "redReceivables", ProPermissionAliasEnum.RED_RECEIVABLES.getI18nMemo()),

    SUPPLIER_CONTACT_ADD(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), "supplierContactAdd", ProPermissionAliasEnum.SUPPLIER_CONTACT_ADD.getI18nMemo()),

    SUPPLIER_COMMUNICATE_ADD(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), "supplierCommunicateAdd", ProPermissionAliasEnum.SUPPLIER_COMMUNICATE_ADD.getI18nMemo()),

    REFUND_ADD(XbbRefTypeEnum.REFUND.getCode(), "refundAdd", ProPermissionAliasEnum.REFUND_ADD.getI18nMemo()),

    QUOTATION_ADD(XbbRefTypeEnum.QUOTATION.getCode(), ProPermissionAliasEnum.QUOTATION_ADD.getAlias(),ProPermissionAliasEnum.QUOTATION_ADD.getI18nMemo()),
    //预收款的新建
    PREPAYMENT_BALANCE_ADD(XbbRefTypeEnum.PREPAYMENT_BALANCE.getCode(), ProPermissionAliasEnum.PAYMENT_SHEET_ADD.getAlias(),ProPermissionAliasEnum.PAYMENT_SHEET_ADD.getI18nMemo()),
    //回款单的新建
    PAYMENT_SHEET_ADD(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), ProPermissionAliasEnum.PAYMENT_SHEET_ADD.getAlias(),ProPermissionAliasEnum.PAYMENT_SHEET_ADD.getI18nMemo()),
    //付款单新增
    PAY_SHEET_ADD(XbbRefTypeEnum.PAY_SHEET.getCode(), ProPermissionAliasEnum.PAY_SHEET_ADD.getAlias(),ProPermissionAliasEnum.PAY_SHEET_ADD.getI18nMemo()),
    //进项发票新增
    PURCHASE_INVOICE_ADD(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), ProPermissionAliasEnum.PURCHASE_INVOICE_ADD.getAlias(),ProPermissionAliasEnum.PURCHASE_INVOICE_ADD.getI18nMemo()),
    //预付款新建
    PREPAY_BALANCE_ADD(XbbRefTypeEnum.PREPAY_BALANCE.getCode(), ProPermissionAliasEnum.PAY_SHEET_ADD.getAlias(),ProPermissionAliasEnum.PAY_SHEET_ADD.getI18nMemo()),
    //回款计划新建
    PAYMENT_TASK_ADD(XbbRefTypeEnum.PAYMENT_TASK.getCode(), ProPermissionAliasEnum.PAYMENT_TASK_ADD.getAlias(), ProPermissionAliasEnum.PAYMENT_TASK_ADD.getI18nMemo()),
    //其他支出单新建
    OTHER_EXPENSE_ADD(XbbRefTypeEnum.OTHER_EXPENSE.getCode(),ProPermissionAliasEnum.OTHER_EXPENSE_ADD.getAlias(),ProPermissionAliasEnum.OTHER_EXPENSE_ADD.getI18nMemo()),
    //其他收入单新建
    OTHER_INCOME_ADD(XbbRefTypeEnum.OTHER_INCOME.getCode(),ProPermissionAliasEnum.OTHER_INCOME_ADD.getAlias(),ProPermissionAliasEnum.OTHER_INCOME_ADD.getI18nMemo()),
    //资金调拨单新建
    FUND_TRANSFER_ADD(XbbRefTypeEnum.FUND_TRANSFER.getCode(),ProPermissionAliasEnum.FUND_TRANSFER_ADD.getAlias(),ProPermissionAliasEnum.FUND_TRANSFER_ADD.getI18nMemo()),

    CLUE_ADD(XbbRefTypeEnum.CLUE.getCode(), ProPermissionAliasEnum.CLUE_ADD.getAlias(),ProPermissionAliasEnum.CLUE_ADD.getI18nMemo()),

    MARKET_ACTIVITY_ADD(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), ProPermissionAliasEnum.MARKET_ACTIVITY_ADD.getAlias(),ProPermissionAliasEnum.MARKET_ACTIVITY_ADD.getI18nMemo()),

    DISTRIBUTOR_ADD(XbbRefTypeEnum.DISTRIBUTOR_MANAGEMENT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_ADD.getAlias(),ProPermissionAliasEnum.DISTRIBUTOR_ADD.getI18nMemo()),

    DISTRIBUTOR_CONTACT_ADD(XbbRefTypeEnum.DISTRIBUTOR_CONTACT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_CONTACT_ADD.getAlias(),ProPermissionAliasEnum.DISTRIBUTOR_CONTACT_ADD.getI18nMemo()),

    DISTRIBUTOR_COMMUNICATE_ADD(XbbRefTypeEnum.DISTRIBUTOR_COMMUNICATE.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_COMMUNICATE_ADD.getAlias(),ProPermissionAliasEnum.DISTRIBUTOR_COMMUNICATE_ADD.getI18nMemo()),

    DISTRIBUTOR_ACCOUNT_ADD(XbbRefTypeEnum.DISTRIBUTOR_ACCOUNT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_ACCOUNT_ADD.getAlias(),ProPermissionAliasEnum.DISTRIBUTOR_ACCOUNT_ADD.getI18nMemo()),

    ORDER_ADD(XbbRefTypeEnum.ORDER.getCode(), ProPermissionAliasEnum.ORDER_ADD.getAlias(),ProPermissionAliasEnum.ORDER_ADD.getI18nMemo()),

    RETURN_ADD(XbbRefTypeEnum.RETURN.getCode(), ProPermissionAliasEnum.RETURN_ADD.getAlias(),ProPermissionAliasEnum.RETURN_ADD.getI18nMemo()),


    ALL_CLUE_ADD(XbbRefTypeEnum.ALL_CLUE.getCode(), ProPermissionAliasEnum.CLUE_ADD.getAlias(),ProPermissionAliasEnum.CLUE_ADD.getI18nMemo()),

    CLUE_PUBLIC_ADD(XbbRefTypeEnum.CLUE_PUBLIC.getCode(), ProPermissionAliasEnum.CLUE_ADD.getAlias(),ProPermissionAliasEnum.CLUE_ADD.getI18nMemo()),

    COMPETITOR_ADD(XbbRefTypeEnum.COMPETITOR.getCode(),ProPermissionAliasEnum.COMPETITOR_ADD.getAlias(), ProPermissionAliasEnum.COMPETITOR_ADD.getI18nMemo()),


    WORK_ORDER_V2_ADD(XbbRefTypeEnum.WORK_ORDER_V2.getCode(),ProPermissionAliasEnum.WORK_ORDER_V2_ADD.getAlias(), ProPermissionAliasEnum.COMPETITOR_ADD.getI18nMemo()),

    SERVICE_PROJECT_ADD(XbbRefTypeEnum.SERVICE_PROJECT.getCode(),ProPermissionAliasEnum.SERVICE_PROJECT_ADD.getAlias(), ProPermissionAliasEnum.SERVICE_PROJECT_ADD.getI18nMemo()),



    ;

    private Integer code;

    private String alias;

    private String memo;

    AddProPermissionAliasEnum(Integer code, String alias, String memo) {
        this.code = code;
        this.alias = alias;
        this.memo = memo;
    }

    public static AddProPermissionAliasEnum getByCode(Integer businessType) {
        for (AddProPermissionAliasEnum item: values()) {
            // 工作报告的日报、周报、月报，请使用 workReportSetService.getVisibleRange
            if (Objects.equals(item.getCode(), businessType)) {
                return item;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
